﻿using System;
using System.Collections.Generic;
using Antlr.Runtime;

namespace SimpleSpreadsheet.Core.Parser
{
    /// <summary>
    /// Base class for different implementations of expression parsers (for possible future use)
    /// </summary>
    public class ExtendedParserBase : Antlr.Runtime.Parser
    {
        protected List<Exception> _exceptions = new List<Exception>();

        public ExtendedParserBase(ITokenStream input) : base(input)
        {
        }

        public ExtendedParserBase(ITokenStream input, RecognizerSharedState state) : base(input, state)
        {
        }

        public bool HasError
        {
            get { return _exceptions.Count > 0; }
        }

        public string ErrorMessage
        {
            get { return GetErrorMessage(_exceptions[0] as RecognitionException, TokenNames); }
        }

        public string ErrorPosition
        {
            get { return GetErrorHeader(_exceptions[0] as RecognitionException); }
        }

        public virtual expression_return Expression()
        {
            throw new NotImplementedException("Method must be overriden");
        }
    }
}